import { Define, EntityObjectFactory } from 'tiny-entity2';
import { AccountRoles } from './accountRoles';
const EntityObjectType = EntityObjectFactory.GetEntityObjectType(process.env.dataBaseType || 'mysql');

@Define.Table({ TableName: "account" })
export class Account extends EntityObjectType<Account>{
    @Define.PrimaryKey()
    id: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        IsIndex: true,
        NotAllowNULL: true
    })
    username: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true
    })
    password: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    storeId: string;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    createTime: number;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    version: number;

    @Define.Mapping({
        Mapping: 'AccountRoles',
        MappingKey: 'accountId'
    })
    accountRoles: AccountRoles[];
}